package com.zby.lease.common.security;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class SecurityUtil {
    private final BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();

    public String md5(String str) {

        if (str != null) {
            return bCryptPasswordEncoder.encode(str);
        }
        return null;
    }
    public boolean checkPassword(String password, String encodePassword) {
        if (password == null || encodePassword == null) {
            return false;
        }
        BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
        return bCryptPasswordEncoder.matches(password, encodePassword);
    }
}
